package com.example.administrator.exkotlin.jetpack


import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log

import com.example.administrator.exkotlin.R
import com.example.administrator.exkotlin.activity.BaseActivity

import com.example.administrator.exkotlin.base.start
import com.example.administrator.exkotlin.jetpack.room.RoomActivity

import com.example.administrator.exkotlin.jetpack.viewmodel.ViewModelActivity
import com.example.administrator.exkotlin.jetpack.workmanager.WorkManagerActivity
import kotlinx.android.synthetic.main.activity_jet_pack.*

/**
 * 使用jetpack组件
 * */
class JetPackActivity : BaseActivity() {
    private val TAG = "JetPackActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_jet_pack)

        initData()
    }


    private fun initData() {
        btn_view_model.setOnClickListener {
            //三种启动方式
            //            Generic.startActivity<ViewModelActivity>(this)
//            val intent = Intent(this, ViewModelActivity::class.java)
//            startActivity(intent)
            ViewModelActivity().start(this)
            Log.i(TAG,"startViewModel")

        }

        btn_room.setOnClickListener {
            RoomActivity().start(this)
            Log.i(TAG,"startRoom")
        }
        btn_work.setOnClickListener {
            WorkManagerActivity().start(this)
            Log.i(TAG,"startWork")
        }

    }
}
